/**
 * Created by 3dgis on 2017/4/4.
 */
import React, {Component} from "react";
import {connect} from "react-redux"
import {search} from '../actions/searchActions'
// @connect((store)=>{
//     return {
//         result:store.search.result
//     }
// })
//Layout = connect(store)(Layout)
class Layout extends Component {
    componentWillMount() {
        //this.props.dispatch(search())
    }

    doSearch=()=> {
        this.props.dispatch(search())
    }

    render() {
        console.log(this.props.search.result);
        const result = this.props.search.result
        if (!result.pois) {
            return (
                <div>
                    <input type="search"/>
                    <button onClick={this.doSearch}>search</button>
                </div>
            )
        }
        return (
            <div>
                <h1>{result.pois[0].name}</h1>
                <div>{result.pois[0].address}</div>
                <div>{result.pois[0].lonlat}</div>
            </div>

        );
    }
}
export default Layout = connect((store) => {
    return {
        search: store.search
    }
})(Layout)